<template>
    <div class="goodsdetail">
        <slider :imgList="goodsData.album"></slider>

        <pannelfooter></pannelfooter>
    </div>
</template>
<script>
    import slider from '../../components/Slider.vue'
    import pannelfooter from '../../components/PannelFooter.vue'
    export default {
        data () {
            return {
                goodsId: this.$route.query.id ? this.$route.query.id : '', // vueRouter传过来的商品id
                goodsData: [], // 商品数据
            }
        },
        components: {
            slider,pannelfooter
        },
        created () {
            this.goodsDetail()
        },
        computed: {

        },
        methods: {
            // 获取商品详情
            goodsDetail () {
                this.$api.goodsDetail({id: this.goodsId, token: this.GLOBAL.getStorage('user_token')}, res => {
                    if (res.status && res.data.length !== 0) {
                        this.goodsData = res.data
                    } else {
                        this.$dialog.alert({
                            mes: '该商品不存在',
                            callback: () => {
                                this.$router.go(-1)
                            }
                        })
                    }
                })
            },
        }
    }
</script>


